package com.yanqu.road.server.cmd.union.cross.trade;

import com.yanqu.road.pb.union.UnionTradeProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.union.trade.CrossUnionTradeMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_UNION_TRADE_ROUTE_PATRONS_SEND, desc = "(加入路线)门客派遣")
public class CrossPatronsSendCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        UnionTradeProto.PatronsSendCrossReqMsg reqMsg = UnionTradeProto.PatronsSendCrossReqMsg.parseFrom(packet.getBytes());
        //List<Integer> patronsIdList = reqMsg.getPatronsIdList();
        int routeId = reqMsg.getRouteId();

        ret = CrossUnionTradeMgr.joinTradeTeam(serverId, packet.getPlayerId(), routeId, reqMsg.getPatronsList());

        if(ret != 0){
            UnionTradeProto.PatronsSendRespMsg.Builder respMsg = UnionTradeProto.PatronsSendRespMsg.newBuilder();
            respMsg.setRet(ret);
            MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.U_UNION_TRADE_ROUTE_PATRONS_SEDN, respMsg));
        }
    }

    @Override
    public void sendData() {

    }
}
